package org.test4j.mock.processor;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.test4j.fortest.spring.ServiceA;
import org.test4j.mock.Mocks;
import org.test4j.mock.stubs.FluentStubsTest;

import java.util.Observer;

@Mocks(value = {
    Observer.class,
    FluentStubsTest.MyNestedService.class,
    ServiceA.class
}, fakeBean = true)
@ContextConfiguration(classes = StubsDemoFakeBeans.class)
public class StubsDemo {
    private StubsDemoMocks mocks = new StubsDemoMocks();

    @Autowired
    private ServiceA serviceA;

    @Test
    void test() {
        mocks.ServiceA(fake -> {
            fake.say$.restReturn("mock value");
        });
        String result = serviceA.say("h");
        Assertions.assertEquals("mock value", result);
    }
}